package com.ai.exception;

import com.ai.exception.code.BaseResponseCode;
import com.ai.exception.code.ResponseCodeInterface;
import lombok.Getter;

/**
 * 业务系统封装
 */
@Getter
public class BusinessException extends RuntimeException {
    /**
     * 异常编号
     */
    private final int code;

    /**
     * 对messageCode 异常信息进行补充说明
     */
    private final String message;

    public BusinessException(int messageCode, String message) {
        super(message);
        this.code = messageCode;
        this.message = message;
    }

    public BusinessException(String message) {
        super(message);
        this.code = BaseResponseCode.OPERATION_ERRO.getCode();
        this.message = message;
    }

    /**
     * 构造函数
     *
     * @param code 异常码
     */
    public BusinessException(ResponseCodeInterface code) {
        this(code.getCode(), code.getMsg());
    }

}
